Hello, again. In
this new activity, we are going to run the
WordCount program using the Hadoop cluster that we previously created using
Docker containers. For this activity, first, you are going to explore the different
MapReduce applications and run your first application. Then you're going to execute
the WordCount application on a text file which contains the different works of
William Shakespeare. Finally, you're going to copy your results outside of
the Hadoop file system. First step, we're going
to copy a command that is available in the
written instructions of this activity. What this command is going to do is that it's going
to open a file, which contains all the
different MapReduce examples available in our cluster. We type enter, and
after we do it, we're going to get a list of the different MapReduce programs available along with
a brief description of what is their function. For this activity, we are
mainly working with WordCount. But before working
with WordCount, we're going to run
an example of Pi, which is a MapReduce
program that estimates Pi using a quasi-Monte
Carlo method. We're going to run the
same command once again, but this time we're going to include Pi at the
end of the command. What is going to happen is
that this is going to bring us a more detailed information on how do we use the Pi program. What we care the most
about is this section on the top where the
usage is described, and pretty much what this is telling us is that
we have to run the program along
with the number of maps and the number
of samples per map. We call the same command again, and I'm going to specify 10
maps with 15 samples per map. I press Enter, and my job is going to start. As we saw at the top, the parameters that we specified are used
by the program, and we can see how our
program is started to work, and we can see the
progress of this work. At this point, the map tasks
have been completed at 80%, and now our job is complete. It took 24 seconds and the
estimated value of Pi is 3.70. After completing
our first example, let's proceed to run WordCount. To do this, we'll
start by looking on the details on how
to use this program. We call this command again, but this time we
write WordCount. As we see, we use this
program by calling it, writing the input files, and also detailing
the output folder. Now we know how
to use WordCount. Let's run it. For this,
we call the program. We write the name of the
input file, which is words, which we previously placed on the the storage file system, and our output directory,
we're going to call it out. We press Enter, and this is going to
initiate our job. After a couple of minutes, we can go at top of
these log messages, and we're going to find a
message just right here, which is going to indicate that our job was completed
successfully. Let's double check if our out directory was indeed
successfully created. For this, we're
going to list again the files in the
distributed file system, and as we see our out
directory is just right there. To look at the content
of the out directory, we simply run the
same command again, but we add out at the end. We will see that the out
directory has two files. The first file, it's a file that confirms that the
job was successful, and the second file
is a text file which contains all the words along
with their respective count. We have to take the text file outside of the
distributed file system. To do this, we're going
to use a function that we already know from
the previous activity. It's the copy to local function. We're going to take
the text file outside, and we're going to call it
local in our local system. We run it. Now we'll
list the files, and we will find the local
TXT file just right here. To exit the container,
we simply type exit, press Enter, and we are back in our local
terminal shell. To take a look at the results
of the WordCount program, I'm going to make a copy of the local TXT file that is inside of the name
not container. I'm going to copy it inside
of my Hadoop folder. I run this, and
after making a copy, I'm going to open
my Hadoop folder and I'm going to open
the text file local. As we see, these are
all the words that appear in the works of
William Shakespeare, along with the count. As a final step, we are
going to delete the cluster. To do this, we run
Docker compose, we write the word down to delete all the containers
associated with the cluster. As we see, now the
containers are deleted, and this concludes our activity.